var cookie = {
    setCookie(c_name, value, expireHours) {
        /*
        *cookie名称，cookie值，以及在多少小时后过期
        * https://www.cnblogs.com/moqiutao/p/7516446.html
        * */
        var exdate = new Date();
        exdate.setTime(exdate.getTime() + expireHours);
        exdate.setDate(exdate.getDate() + expireHours);
        document.cookie = c_name + "=" + escape(value) + ((expireHours == null) ? "" : ";expires=" + exdate.toGMTString());
    },
    getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return (arr[2]);
        else
            return null;
    },
    delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = cookie.getCookie(name);
        if (cval != null)
            document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
    }
}
export default cookie;
